package io.afu.nginxhelper.dto.common;

import io.afu.nginxhelper.constant.NgxConst;

public class AccessLog {
    public final String KEY = "access_log";

    private String file;

    private String level;

    public void turnOff() {
        this.file = "off";
        this.level = null;
    }

    public void turnOn(String logPath) {
        this.file = logPath;
    }

    public void turnOn(String filePath,String level){
        this.file = filePath;
        this.level = level;
    }

    public String getFile() {
        return file;
    }

    public void setFile(String file) {
        this.file = file;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(KEY)
                .append(NgxConst.SEP)
                .append(file);
        if (level != null){
            sb.append(NgxConst.SEP)
                    .append(level);
        }
        sb.append(NgxConst.END_MARK);
        return sb.toString();
    }
}
